//
//  NormolTableViewCell.m
//  10-CustomCell-易车
//
//  Created by LL.F on 16/7/27.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "NormolTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation NormolTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _leftImage = [[UIImageView alloc] init];
//        _leftImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_leftImage];
        
        _summaryLabel = [[UILabel alloc] init];
        _summaryLabel.numberOfLines = 0;
//        _summaryLabel.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_summaryLabel];
    }
    return self;
}
-(void)layoutSubviews
{

    [super layoutSubviews];
    CGFloat topMarin = 10;
    CGFloat leftMarin = 5;
    CGFloat bottomMarin = 5;
    CGFloat rightMarin = 5;
    
    _leftImage.frame = CGRectMake(leftMarin, topMarin, self.frame.size.width / 3, self.frame.size.height - topMarin - bottomMarin);
    _summaryLabel.frame = CGRectMake(leftMarin + _leftImage.frame.size.width + leftMarin, topMarin, self.frame.size.width * 2 / 3 - leftMarin - rightMarin * 2, _leftImage.frame.size.height);
    
}

-(void)setModel:(CellModel *)model
{
    _model = model;
    
    self.summaryLabel.text = model.title;
    
    //    self.leftImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:model.picCover]]];
    
   
    [self.leftImage sd_setImageWithURL:[NSURL URLWithString:model.picCover] placeholderImage:[UIImage imageNamed:@"newsPic1"]];
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
